Skip to content

Fix tagMetadata extension diagnostic targets#10776

Open
kiwigitops wants to merge 1 commit into
microsoft:mainfrom
kiwigitops:fix-openapi-tagmetadata-extension-target
Open

Fix tagMetadata extension diagnostic targets#10776
kiwigitops wants to merge 1 commit into
microsoft:mainfrom
kiwigitops:fix-openapi-tagmetadata-extension-target

Conversation

@kiwigitops
Copy link
Copy Markdown

Closes #10767

This keeps the OpenAPI extension-key validation tied to the metadata object literal, so invalid keys such as custom are reported on the offending property instead of the tag name.

Verification:

  • npx pnpm --filter @typespec/openapi build
  • npx pnpm --filter @typespec/openapi test -- decorators.test.ts

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 1, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/openapi@10776

commit: f0bf9be

expectDiagnostics(diagnostics, {
code: "@typespec/openapi/invalid-extension-key",
message: `OpenAPI extension must start with 'x-' but was 'custom'`,
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectDiagnostics takes in a pos and the actual value can be retrieved if using compileAndDiagnose and using a marker in the code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

All changed packages have been documented.

  • @typespec/openapi
Show changes

@typespec/openapi - fix ✏️

Fix tagMetadata extension diagnostic targets

@kiwigitops kiwigitops force-pushed the fix-openapi-tagmetadata-extension-target branch from 2fc1378 to 85c43b1 Compare June 1, 2026 19:59
@kiwigitops
Copy link
Copy Markdown
Author

kiwigitops commented Jun 1, 2026

Updated: the test now uses compileAndDiagnose with a /*custom*/ marker and asserts pos: pos.custom.pos. I also added the Chronus changeset for @typespec/openapi.

Signed-off-by: kiwigitops <kiwisclubco@gmail.com>
@kiwigitops kiwigitops force-pushed the fix-openapi-tagmetadata-extension-target branch from 85c43b1 to f0bf9be Compare June 1, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tagMetadata custom property without x report error on wrong location

2 participants